<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer"));
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>注册</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/DDMBase.js"></script>

<link rel="stylesheet" href="${path }/resource/weixin/css/register.css">

</head>
<body>
	<!-- 头部 -->
	<jsp:include page="_top.jsp"></jsp:include>
	<!-- 头部结束 -->
	<!-- 主内容 -->
	<!--手机注册  -->
	<div class="content-main">
		<form class="" method="post" id="dataform"
			onsubmit="javascripr:return false;">
			<input name="uuid" id="uuid" type="hidden">
			<div class="am-input-group margin-t1">
				<span class="am-input-group-label"><i
					class="am-icon-mobile am-icon-fw am-icon-sm color-9"></i></span> <input
					type="number" id="phone" name="tel" dataType="m"
					class="am-form-field" placeholder="请输入手机号码">
				<button class="verification-code color-w back-y" id="btnSendCode"
					onclick="sendMessage()">获取验证码</button>
			</div>
			<div class="am-input-group">
				<span class="am-input-group-label"><i
					class="am-icon-credit-card am-icon-fw color-9"></i></span> <input
					type="number" datatype="*4-4" name="yzm" class="am-form-field"
					placeholder="请输入验证码">
			</div>
			<div class="login-div">
				<button class="login-btn color-w back-y" type="button"
					onclick="myForm.submit()">注册</button>
			</div>

		</form>
		<div class="float-r margin-t1 color-y">
			已有账号? <a href="${path }/visitor/redirect/login " class="color-y">
				登录 </a>
		</div>
	</div>
	<!-- 留白 -->
	<div class="blank-space back-w"></div>
	<!-- 主内容结束 -->
	<script type="text/javascript">
		var uuid = $.query.get("value");
		$("#uuid").val(uuid);

		/*会员注册判断  */
		var myForm = MForm.initForm({
			invokeUrl : "${path}/visitor/reg",
			afterSubmit : function(loj) {
				layer.open({
					shade : false,
					content : '注册成功',
					className : 'showBox',
					time : 1,
					end : function(elem) {
						if(isWeiXin()){
	  		        		MTools.redirect("${path }/common/wxLogin");
						}else{
						MTools.redirect("${path }/index");
						}
					}
				});
			}
		});
		  function isWeiXin(){ 
				var ua = window.navigator.userAgent.toLowerCase(); 
				if(ua.match(/MicroMessenger/i) == 'micromessenger'){ 
					return true; 
				}else{ 
				return false; 
				} 
			} 
		var InterValObj; //timer变量，控制时间
		var count = 60; //间隔函数，1秒执行
		var curCount;//当前剩余秒数
		function sendMessage() {
			if ((/^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/)
					.test($('#phone').val())) {
				//向后台发送处理数据
				$.AjaxProxy({
					p : {
						phone : $('#phone').val(),
					},
					a : false
				}).invoke("${path}/visitor/getCode", function(loj) {
					curCount = count;
					$("#btnSendCode").attr("disabled", "true");
					$("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
					InterValObj = window.setInterval(SetRemainTime, 1000);

				});
			} else {
				layer.open({
					shade : false,
					content : '手机号不正确',
					className : 'showBox',
					time : 1,
				})
			}

		}

		//timer处理函数
		function SetRemainTime() {
			if (curCount == 0) {
				$("#btnSendCode").removeAttr("disabled");//启用按钮
				$("#btnSendCode").html("重新发送验证码");
				window.clearInterval(InterValObj);//停止计时器
			} else {
				curCount--;
				$("#btnSendCode").html("请在" + curCount + "秒内输入验证码");
			}
		}
	</script>

</body>
</html>